package com.honey.mybatis.generator;

import com.honey.core.dbmapping.introspect.IntrospectSchema;
import com.honey.core.dbmapping.introspect.IntrospectSchemaColumn;
import com.honey.mybatis.generator.condition.ProduceCondition;
import com.honey.mybatis.generator.criteria.ProduceCriterion;
import com.honey.mybatis.generator.criteria.ProduceGeneratedCriteria;
import com.honey.mybatis.generator.dao.ProduceBaseDaoImplements;
import com.honey.mybatis.generator.dao.ProduceBaseDaoInterface;
import com.honey.mybatis.generator.dao.ProduceDaoImplements;
import com.honey.mybatis.generator.dao.ProduceDaoInterface;
import com.honey.mybatis.generator.dependent.DependentModel;
import com.honey.mybatis.generator.dependent.ProduceExtendDependentBaseDao;
import com.honey.mybatis.generator.dependent.ProduceInjectionDependentDaoImplements;
import com.honey.mybatis.generator.dependent.ProduceInjectionDependentDaoInterface;
import com.honey.mybatis.generator.entity.ProduceBlobEntityClass;
import com.honey.mybatis.generator.entity.ProduceEntityClass;
import com.honey.mybatis.generator.model.ProduceModel;
import com.honey.mybatis.generator.model.ProduceTableCloumnEnum;
import com.honey.mybatis.generator.page.ProducePage;

public class MybatisFactory {
	
	public static AbstractProduceJavaCompilation getAbstractProduceJavaCompilation(
			MybatisClass mybatis,
			MybatisPlugin mybatisPlugin,
			IntrospectSchema introspectSchema, 
			IntrospectSchemaColumn introspectSchemaColumn
	){
		return mybatis.produceJavaCompilation(
				mybatisPlugin, 
				introspectSchema, 
				introspectSchemaColumn
		);
	}
	
	public enum MybatisClass{
		CONDITION{
			AbstractProduceJavaCompilation produceJavaCompilation(
					MybatisPlugin mybatisPlugin,
					IntrospectSchema introspectSchema, 
					IntrospectSchemaColumn introspectSchemaColumn
			){
				return new ProduceCondition(
						mybatisPlugin,
						introspectSchema, 
						introspectSchemaColumn
				);
			}
		}
		,
		PAGE{
			AbstractProduceJavaCompilation produceJavaCompilation(
					MybatisPlugin mybatisPlugin,
					IntrospectSchema introspectSchema, 
					IntrospectSchemaColumn introspectSchemaColumn
			){
				return new ProducePage(
						mybatisPlugin,
						introspectSchema, 
						introspectSchemaColumn
				);
			}
		}
		,
		GENERATED_CRITERIA{
			AbstractProduceJavaCompilation produceJavaCompilation(
					MybatisPlugin mybatisPlugin,
					IntrospectSchema introspectSchema, 
					IntrospectSchemaColumn introspectSchemaColumn
			){
				return new ProduceGeneratedCriteria(
						mybatisPlugin,
						introspectSchema, 
						introspectSchemaColumn
				);
			}
		},
		
		CRITERION{
			AbstractProduceJavaCompilation produceJavaCompilation(
					MybatisPlugin mybatisPlugin,
					IntrospectSchema introspectSchema, 
					IntrospectSchemaColumn introspectSchemaColumn
			){
				return new ProduceCriterion(
						mybatisPlugin,
						introspectSchema, 
						introspectSchemaColumn
				);
			}
		},
		
		PRODUCE_MODEL{
			AbstractProduceJavaCompilation produceJavaCompilation(
					MybatisPlugin mybatisPlugin,
					IntrospectSchema introspectSchema, 
					IntrospectSchemaColumn introspectSchemaColumn
			){
				return new ProduceModel(
						mybatisPlugin,
						introspectSchema, 
						introspectSchemaColumn
				);
			}
		},
		
		PRODUCE_MODEL_TABLE_CLOUMN{
			AbstractProduceJavaCompilation produceJavaCompilation(
					MybatisPlugin mybatisPlugin,
					IntrospectSchema introspectSchema, 
					IntrospectSchemaColumn introspectSchemaColumn
			){
				return new ProduceTableCloumnEnum(
						mybatisPlugin,
						introspectSchema, 
						introspectSchemaColumn
				);
			}
		},
		
		DAO_INTERFACE{
			AbstractProduceJavaCompilation produceJavaCompilation(
					MybatisPlugin mybatisPlugin,
					IntrospectSchema introspectSchema, 
					IntrospectSchemaColumn introspectSchemaColumn
			){
//				return new ProduceDaoInterface(
//						mybatisPlugin,
//						introspectSchema, 
//						introspectSchemaColumn
//				);
				if(mybatisPlugin.getDependentModel() == DependentModel.EXTEND){
					return new ProduceDaoInterface(
						mybatisPlugin,
						introspectSchema, 
						introspectSchemaColumn
					);
				}else{
					return new ProduceInjectionDependentDaoInterface(
						mybatisPlugin,
						introspectSchema, 
						introspectSchemaColumn
					);
				}
			}
		},
		
		DAO_IMPLEMENTS{
			AbstractProduceJavaCompilation produceJavaCompilation(
					MybatisPlugin mybatisPlugin,
					IntrospectSchema introspectSchema, 
					IntrospectSchemaColumn introspectSchemaColumn
			){
//				return new ProduceDaoImplements(
//						mybatisPlugin,
//						introspectSchema, 
//						introspectSchemaColumn
//				);
				ProduceDaoImplements answer = null;
				if(mybatisPlugin.getDependentModel() == DependentModel.EXTEND){
					answer = new ProduceDaoImplements(
							mybatisPlugin,
							introspectSchema, 
							introspectSchemaColumn
					);
				}else{
					answer = new ProduceInjectionDependentDaoImplements(
							mybatisPlugin,
							introspectSchema, 
							introspectSchemaColumn
					);
				}
				
				return answer ;
			}
		},
		
		BASE_DAO_IMPLEMENTS{
			AbstractProduceJavaCompilation produceJavaCompilation(
					MybatisPlugin mybatisPlugin,
					IntrospectSchema introspectSchema, 
					IntrospectSchemaColumn introspectSchemaColumn
			){

//				return new ProduceBaseDao(
//						mybatisPlugin,
//						introspectSchema, 
//						introspectSchemaColumn
//				);
				ProduceBaseDaoImplements answer = null;
				if(mybatisPlugin.getDependentModel() == DependentModel.INJECTION){
					answer = new ProduceBaseDaoImplements(
							mybatisPlugin,
							introspectSchema, 
							introspectSchemaColumn
					);
				}else{
					answer = new ProduceExtendDependentBaseDao(
							mybatisPlugin,
							introspectSchema, 
							introspectSchemaColumn
					);
				}
				return answer ;
			}
		},
		
		BASE_DAO_INTERFACE{
			AbstractProduceJavaCompilation produceJavaCompilation(
					MybatisPlugin mybatisPlugin,
					IntrospectSchema introspectSchema, 
					IntrospectSchemaColumn introspectSchemaColumn
			){
				ProduceBaseDaoInterface answer = null;
				if(mybatisPlugin.getDependentModel() == DependentModel.EXTEND){
					answer = new ProduceBaseDaoInterface(mybatisPlugin, introspectSchema, introspectSchemaColumn);
				}
				return answer ;
			}
		},
		ENTITY_CLASS{
			AbstractProduceJavaCompilation produceJavaCompilation(
					MybatisPlugin mybatisPlugin,
					IntrospectSchema introspectSchema, 
					IntrospectSchemaColumn introspectSchemaColumn
			){
				return new ProduceEntityClass(
						mybatisPlugin,
						introspectSchema, 
						introspectSchemaColumn
				);
			}
		},
		
		BLOB_ENTITY_CLASS{
			AbstractProduceJavaCompilation produceJavaCompilation(
					MybatisPlugin mybatisPlugin,
					IntrospectSchema introspectSchema, 
					IntrospectSchemaColumn introspectSchemaColumn
			){
				return new ProduceBlobEntityClass(
						mybatisPlugin,
						introspectSchema, 
						introspectSchemaColumn
				);
			}
		},
		
		;
		abstract AbstractProduceJavaCompilation produceJavaCompilation(
				MybatisPlugin mybatisPlugin,
				IntrospectSchema introspectSchema, 
				IntrospectSchemaColumn introspectSchemaColumn
		); 
	}
}
